Skip to content

Add safe uninitialized GEMM overwrite paths - #196

Merged
shinaoka merged 2 commits into
mainfrom
codex/issue-188-uninit-gemm
Jul 31, 2026
Merged

Add safe uninitialized GEMM overwrite paths#196
shinaoka merged 2 commits into
mainfrom
codex/issue-188-uninit-gemm

Conversation

@shinaoka

Copy link
Copy Markdown
Member

Summary

  • Add explicit-context overwrite-only MaybeUninit<T> entry points for einsum2, dot-general, and raw batched GEMM.
  • Route naive, system BLAS, and injected BLAS providers through beta-zero overwrite paths without reading the destination.
  • Add checked output injectivity, conservative input/output overlap rejection, checked arithmetic, non-contiguous temporary/writeback handling, and feature-specific differential/regression tests.
  • Migrate non-Faer strided-opteinsum intermediate pooling to overwrite-only storage while preserving owned-input paths.
  • Raise cblas-inject to 0.1.2 for the exact-zero beta contract.

Faer boundary

Faer 0.24.4 does not expose a typed API that permits a MatMut<T> overwrite over MaybeUninit<T>. The Faer-only public uninitialized entry points therefore return EinsumError::Unsupported and retain the initialized compatibility path. This PR does not use an unsafe cast, early assume_init, or zero-fill workaround. The remaining Faer implementation is tracked in strided-rs#195.

This is the safe backend portion of strided-rs#188; it intentionally does not claim that the Faer portion is complete.

Verification

  • cargo fmt --all -- --check
  • git diff --check
  • cargo test --workspace with CARGO_BUILD_JOBS=4 and linker threads limited to 1 to avoid the local Rust 1.97 linker resource failure
  • strided-einsum2 feature matrix: no-default, Faer, BLAS, and blas-inject
  • strided-opteinsum feature matrix: no-default, Faer, BLAS, and blas-inject
  • injected BLAS fallback and poisoned-C overwrite testsnnRefs

@shinaoka
shinaoka merged commit 50cbaf5 into main Jul 31, 2026
5 checks passed
@shinaoka
shinaoka deleted the codex/issue-188-uninit-gemm branch July 31, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant